package com.afkt.project.ui.slice;


import com.afkt.project.base.app.BaseActivity;
import com.afkt.project.model.bean.CommodityEvaluateBean;
import com.afkt.project.ui.adapter.SliderAdapter;
import com.ohos.afkt.ResourceTable;
import ohos.agp.components.*;

import java.util.ArrayList;
import java.util.List;

public class RecyItemSlideActivity extends BaseActivity {

    /**
     * 标题栏
     */
    private DirectionalLayout bar_layout;
    private DirectionalLayout bar;
    private Image slider_return;

    private ListContainer listContainer;
    private List<CommodityEvaluateBean> lists = new ArrayList<>();

    @Override
    protected int baseLayoutId() {
        return ResourceTable.Layout_base_view_listContainer_slider;
    }

    @Override
    protected void initView() {
        bar_layout = (DirectionalLayout) findComponentById(ResourceTable.Id_slider_bar_layout);
        bar = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_recycle_slider_bar, null, false);
        bar_layout.addComponent(bar);
        slider_return = (Image) bar.findComponentById(ResourceTable.Id_silder_return);

        listContainer = (ListContainer) findComponentById(ResourceTable.Id_slider_list);
        for (int i = 0; i < 40; i++) {
            lists.add(CommodityEvaluateBean.newCommodityEvaluateBean());
        }
        listContainer.setItemProvider(new SliderAdapter(lists,this));
    }

    @Override
    protected void initListener() {
        slider_return.setClickedListener(component -> onBackPressed());
    }

    @Override
    protected void onBackground() {
        bar_layout.removeComponent(bar);
        super.onBackground();
    }
}
